package edu.upc.clase.demo.dao.impl;

import edu.upc.clase.demo.dao.PersonaDao;
import edu.upc.clase.demo.dao.UsuarioDao;
import edu.upc.clase.demo.entity.Persona;
import edu.upc.clase.demo.entity.Usuario;
import java.util.List;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
import org.springframework.stereotype.Repository;


/**
 *
 * @author Jose Luis Carrillo
 */
@Repository
public class PersonaDaoImpl extends SimpleJdbcDaoSupport implements PersonaDao  {

    private static Logger log = LoggerFactory.getLogger(PersonaDaoImpl.class);
    
    @Autowired
    public PersonaDaoImpl(DataSource dataSource) {
            log.info("Asignando el dataSource");
            setDataSource(dataSource);
    }
      
    @Override
    public Integer insertar(Persona persona) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void actualizar(Persona persona) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void eliminar(Persona persona) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Persona buscar(Integer id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Persona buscar(String correo) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public List<Persona> buscarTodos() {
         return getSimpleJdbcTemplate().query(
                        "select CoPersona,NoPersona,NoApellidoPaterno,NoApellidoMaterno from persona",
                        new BeanPropertyRowMapper<Persona>(Persona.class));
    }
    
}
